package vsjgl;

import java.io.IOException;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;


public class VSJGL {
	private int FPS = 60;

	public void start(int width,int height){
		try {
			
			Display.setDisplayMode(new DisplayMode(width,height));
			Display.create();
			InitGL(width,height);
		} catch (LWJGLException e) {
			e.printStackTrace();
		}
	

		Square square = new Square(20,20,20,20);

		Display.setTitle("");
		while(!Display.isCloseRequested())
		{
			GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);  
			square.draw();
			this.update();
			
		}
	}

	/** 
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) {
		VSJGL app = new VSJGL();
		app.start(800,600);
	}
	public void InitGL(int width,int height)
	{
		
		GL11.glEnable(GL11.GL_BLEND);
		//GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
		GL11.glEnable(GL11.GL_TEXTURE_2D);
		GL11.glMatrixMode(GL11.GL_PROJECTION);
		GL11.glLoadIdentity();
		GL11.glOrtho(0, width, height, 0, 1, -1);
		GL11.glMatrixMode(GL11.GL_MODELVIEW);

		
	}
	public void update(){
		Display.sync(FPS);
		
		Display.update();
		
	}
	public void SetFPS(int a){
		this.FPS = a;
	}

}
